View Javadoc

1   /**
2    * Copyright 2008 WebPhotos
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package net.sf.webphotos.web.action;
17  
18  import javax.servlet.http.HttpServletRequest;
19  import javax.servlet.http.HttpServletResponse;
20  import net.sf.webphotos.dao.jpa.AlbumDAO;
21  import org.apache.commons.logging.Log;
22  import org.apache.commons.logging.LogFactory;
23  import org.apache.struts.action.Action;
24  import org.apache.struts.action.ActionForm;
25  import org.apache.struts.action.ActionForward;
26  import org.apache.struts.action.ActionMapping;
27  
28  /**
29   *
30   * @author gsilva
31   */
32  public class IndexAction extends Action {
33  
34      private static final String SUCCESS = "success";
35      private static final Log log = LogFactory.getLog(IndexAction.class);
36  
37      private AlbumDAO albunsDAO;
38  
39      /**
40       * This is the action called from the Struts framework.
41       * @param mapping The ActionMapping used to select this instance.
42       * @param form The optional ActionForm bean for this request.
43       * @param request The HTTP Request we are processing.
44       * @param response The HTTP Response we are processing.
45       * @throws java.lang.Exception
46       * @return
47       */
48      @Override
49      public ActionForward execute(ActionMapping mapping, ActionForm form,
50              HttpServletRequest request, HttpServletResponse response)
51              throws Exception {
52  
53          log.info("Starting Action \"" + this.getClass().getName() + "\"");
54  
55          request.setAttribute("requestURL", request.getRequestURL());
56  
57          request.setAttribute("albunsVO", albunsDAO.findAll());
58  
59          return mapping.findForward(SUCCESS);
60      }
61  
62      /**
63       * @return the albunsDAO
64       */
65      public AlbumDAO getAlbunsDAO() {
66          return albunsDAO;
67      }
68  
69      /**
70       * @param albunsDAO the albunsDAO to set
71       */
72      public void setAlbunsDAO(AlbumDAO albunsDAO) {
73          this.albunsDAO = albunsDAO;
74      }
75  }